<?php
namespace app\admin\controller;
class Uservip extends Base
{
    //计算属性html
    public function lists(){
        if(is_post()){
            $d = $this->post;
            $map = [];
            if($d['keyword']!='') $map[] = ['and','a.order_no|b.username','like',$d['keyword']];
            if($d['level']!='') $map[] = ['and','a.after_level','=',$d['level']];
            if($d['pay_type']!='') $map[] = ['and','a.pay_type','=',$d['pay_type']];
            if($d['pay_status']!='') $map[] = ['and','a.pay_status','=',$d['pay_status']];
            $w  = where($map);
            $rs = $this->db->query("
                select
                    a.*,b.username
                from
                    user_vip a
                inner join
                    user b on a.user_id = b.id
                $w[0] order by a.id desc".limit($d['page'],$d['limit']), $w[1],'',true);
            $rule = [
                'pay_status'=>function($v){return c("type.pay_status.$v");},
                'after_level'=>function($v){return c("type.user_level.$v");},
                'pay_type'=>function($v){return c("type.pay_type.$v");},
                'pay_time' => 'com_time_format',
                'create_time' => 'com_time_format',
            ];
            $data = com_format($rs[0],$rule);
            if($rs){
                suc($data,$rs[1]);
            }else{
                suc([],0);
            }
        }

        $this->fetch();
    }
}
?>
